-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for RSpec to previews as test cases #1408
Add support for RSpec to previews as test cases #1408
Conversation
4e0cb29
to
7ed426c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful! To little surprise, I'd love to see a test for this ❤️. IMO we should add example rspec tests to the example app. Would you mind doing so in this PR? Just a single test that uses render_preview
is sufficient for now, but IMO we should expand what we have for the sake of example.
Good idea, I'll do that 👍🏼 |
7ed426c
to
cdb909f
Compare
4c2c84d
to
5251fea
Compare
Excuse the 👊🏼 -pushing but I've added the For now there is only one rspec file covering the fix in this PR. I've added @joelhawksley Should I go ahead and enable this also on CI by running |
@thutterer yes, let's enable this on CI and remove the |
5251fea
to
c0e3fa5
Compare
c0e3fa5
to
12dfdde
Compare
Done, test coverage back to 100% 💚 I had to move the |
7e4d13c
to
43c2244
Compare
Fantastic! Thanks so much for adding this support ❤️ |
* Add rspec-rails gem * Add support for render_previews in RSpec tests * Enable RSpec tests on CI * Update lib/view_component/render_preview_helper.rb * Update lib/view_component/render_preview_helper.rb * Update Gemfile Co-authored-by: Joel Hawksley <joelhawksley@github.com>
* Add rspec-rails gem * Add support for render_previews in RSpec tests * Enable RSpec tests on CI * Update lib/view_component/render_preview_helper.rb * Update lib/view_component/render_preview_helper.rb * Update Gemfile Co-authored-by: Joel Hawksley <joelhawksley@github.com>
What are you trying to accomplish?
I've noticed that the (Experimental) Previews as test cases don't support RSpec yet, because of how it builds the class name in which it expects the preview:
https://github.com/github/view_component/blob/1a2e39d044f2be8c4dd18fe14d4aa5a3812b79f0/lib/view_component/render_preview_helper.rb#L13-L16
What approach did you choose and why?
This PR adds support for RSpec by checking
self.respond_to?(:described_class)
and if so, using"#{self.described_class}Preview"
as the preview class name.Anything you want to highlight for special attention from reviewers?
docs/index.md
as I hope Prevent adding existing autoload_paths #1383 gets merged before this one (or eventually).